Component({
  properties: {
    isOpen: {
      type: Boolean,
      value: false,
    },
    leftList: {
      type: Array,
      value: [],
    },
    rightList: {
      type: Array,
      value: [],
    },
  },
  /**
   * 页面的初始数据
   */
  data: {
    selectData: [], //选中数据
  },
  methods: {
    // 计算元素剩余位置
    getdocumentInfo(str) {



    }, 
    // 关闭所有事件
    allClose() {
      let new_leftList = [];
      let new_rightList = [];
      this.triggerEvent("isOpen", false); 
      //     关闭左边
      this.properties.leftList.forEach((item, index) => {
        item.open = false;
        new_leftList.push(item);
        return item;
      })
      //     关闭右边
      this.properties.rightList.map((item, index) => {
        item.open = false;
        new_rightList.push(item);
        return item;
      });
      this.setData({
        leftList: new_leftList,
        rightList: new_rightList
      })
    },
    // 左边点击事件
    onLeftLabelClick(e) {
      this.allClose();//点击之前先关闭所有。
      var that = this;
      const {
        key
      } = e.currentTarget.dataset;
      let new_leftList = [];
      this.properties.leftList.map((item, index) => {
        if (index === key) {
          item.open = !item.open;
          that.isOpen = item.open;
          that.triggerEvent("isOpen", item.open); 
        } else {
          item.open = false;
        }
        new_leftList.push(item);
        return item;
      })

      this.setData({
        leftList: new_leftList
      });
    }, // 右边点击事件
    onRightLabelClick(e) {
      const {
        key
      } = e.currentTarget.dataset;
      console.log(key);
    }, // 左边选中的数据
    onLeftSelect(item) {
      console.log(item)
    }, // 右边边选中的数据
    onRightSelect(item) {
      console.log(item)
    }

  }
})